// Learn TypeScript:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html

import { Component, _decorator } from "cc";

const { ccclass, property } = _decorator;


@ccclass
export default class EC extends Component {

    private static instance: EC = null;
    protected onLoad(): void {
        EC.instance = this;
    }
    public static send(evt: string, ...args: any[]) {

        this.instance.node.emit(evt, ...args);
    }
    public static on(evt: string, cb: Function, target?: any) {
        this.instance.node.on(evt, cb, target);
    }
    public static off(evt: string, cb?: Function, target?: any) {
        this.instance.node.off(evt, cb, target);
    }
    public static once(evt: string, cb: Function, target?: any) {
        this.instance.node.once(evt, cb, target);
    }
}
window['EC'] = EC;